<?php
use setasign\Fpdi\Fpdi;
// or for usage with TCPDF:
// use setasign\Fpdi\Tcpdf\Fpdi;

// or for usage with tFPDF:
// use setasign\Fpdi\Tfpdf\Fpdi;

// setup the autoload function
require_once('vendor/autoload.php');

// initiate FPDI
$pdf = new Fpdi();
// add a page
$pdf->AddPage();
// set the source file
// $pdf->setSourceFile("E-EL-0162.pdf");
// $pdf->setSourceFile("12.pdf");
// $pdf->setSourceFile("YD 702-2018-I.pdf");
$filename = "zzxcxc.pdf";
$pageCount = $pdf->setSourceFile($filename);
// import page 1
$lv = isset($_GET['lv']) ? (int)$_GET['lv'] : 1;
//导入单页
for($pageNo=1; $pageNo<=$lv; $pageNo++){
	if($pageNo>$pageCount){
		break;
	}
	$tplId = $pdf->importPage($pageNo);
	// use the imported page and place it at point 10,10 with a width of 100 mm
	// $pdf->useTemplate($tplId, 10, 10, 100);
	// $pdf->useTemplate($tplId, 0, 0, 230);
	// $pdf->useTemplate($tplId, array('adjustPageSize'=>true));
	$s = $pdf->getTemplatesize($tplId);
	if($pageNo>1){
		$pdf->AddPage($s['orientation'], $s);
	}
	$pdf->useImportedPage($tplId);

}
$pdf->Output('D', $filename);